<?php

function sendsms($mobile, $content,$code='SMS_70555235'){
	include "smsdk/TopSdk.php";
	date_default_timezone_set('Asia/Shanghai'); 
	$c = new TopClient;
	// $c->appkey = '24031664';//APPKEY
	$c->appkey = $GLOBALS['_CFG']['appkey'];//APPKEY
	// $c->secretKey = '20a641dba155b500d94021ff65014999';//APPSECRETKEY
	$c->secretKey = $GLOBALS['_CFG']['secretKey'];//APPSECRETKEY
	$req = new AlibabaAliqinFcSmsNumSendRequest;
	// $req->setExtend("24031664");
	$req->setExtend($GLOBALS['_CFG']['appkey']);
	$req->setSmsType("normal");
	$req->setSmsFreeSignName("司令羊"); 
	// $req->setSmsParam("{\"code\":\"".$code."\",\"product\":\"司令羊\",\"item\":\"司令羊\"}");
	
	
	
	$req->setSmsParam($content);
	// $req->setSmsTemplateCode("SMS_67165619");
	$req->setSmsTemplateCode($code);
	$req->setRecNum($mobile);
	$resp = $c->execute($req);
	
	
	if($resp->result->success!='true'){
		return false;
	}else{
		return true;
	}

	
}


function ismobile($mobile){
	return (strlen($mobile) == 11 || strlen($mobile) == 12) && (preg_match("/^13\d{9}$/", $mobile) || preg_match("/^14\d{9}$/", $mobile) || preg_match("/^15\d{9}$/", $mobile) || preg_match("/^18\d{9}$/", $mobile) || preg_match("/^0\d{10}$/", $mobile) || preg_match("/^0\d{11}$/", $mobile));
}

function getverifycode() {
	$length = 6;
	PHP_VERSION < '4.2.0' && mt_srand((double)microtime() * 1000000);
	$hash = sprintf('%0'.$length.'d', mt_rand(0, pow(10, $length) - 1));
	return $hash;
}

function ihuyi_Post($curlPost,$url){
		$curl = curl_init();
		curl_setopt($curl, CURLOPT_URL, $url);
		curl_setopt($curl, CURLOPT_HEADER, false);
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($curl, CURLOPT_NOBODY, true);
		curl_setopt($curl, CURLOPT_POST, true);
		curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPost);
		$return_str = curl_exec($curl);
		curl_close($curl);
		return $return_str;
}

function xml_to_array($xml){
	$reg = "/<(\w+)[^>]*>([\\x00-\\xFF]*)<\\/\\1>/";
	if(preg_match_all($reg, $xml, $matches)){
		$count = count($matches[0]);
		for($i = 0; $i < $count; $i++){
		$subxml= $matches[2][$i];
		$key = $matches[1][$i];
			if(preg_match( $reg, $subxml )){
				$arr[$key] = xml_to_array( $subxml );
			}else{
				$arr[$key] = $subxml;
			}
		}
	}
	return @$arr;
}
?>